Imports System.Data.SqlClient

Friend Class DBSProcText_Factory
    Inherits DBBase

    Public Sub ClearText( _
         ByVal lViewID As Long, _
         ByVal lViewRevID As Long)

        Dim sSQL As String = "delete from tDDSProcText"
        sSQL = sSQL & " where"
        sSQL = sSQL & "   [SProcID]=" & lViewID
        sSQL = sSQL & "   and [SProcRevID]=" & lViewRevID

        MyBase.ExecuteNonQuery(sSQL)
    End Sub

    Public Sub AddText( _
        ByVal lSProcID As Long, _
        ByVal lSProcRevID As Long, _
        ByVal iOrder As Integer, _
        ByVal sText As String)

        Dim sSQL As String = "insert into tDDSProcText ("
        sSQL = sSQL & " [SProcID],"
        sSQL = sSQL & " [SProcRevID],"
        sSQL = sSQL & " [Order],"
        sSQL = sSQL & " [Text]) values ("
        sSQL = sSQL & lSProcID & ","
        sSQL = sSQL & lSProcRevID & ","
        sSQL = sSQL & iOrder & ","
        sSQL = sSQL & ValueToDBValue(sText) & ")"

        MyBase.ExecuteNonQuery(sSQL)
    End Sub

    Public Function GetText( _
        ByVal lSProcID As Long, _
        ByVal lSProcRevID As Long) As String

        Dim sText As String = ""

        Dim sSQL As String = "select"
        sSQL = sSQL & "     [Text]"
        sSQL = sSQL & " from"
        sSQL = sSQL & "     tDDSProcText a"
        sSQL = sSQL & " where"
        sSQL = sSQL & "     [SProcID]=" & ValueToDBValue(lSProcID)
        sSQL = sSQL & "     and [SProcRevID]=" & ValueToDBValue(lSProcRevID)
        sSQL = sSQL & " order by"
        sSQL = sSQL & "     [Order]"

        Dim oData As DataTable = MyBase.ExecuteReadToDataTable(sSQL)

        For Each oRow As DataRow In oData.Rows
            sText = sText & oRow.Item(0)
        Next

        oData.Dispose()

        Return sText
    End Function
End Class
